package com.java.system.controller;

import com.sun.deploy.net.HttpUtils;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.RequestMapping;
import com.fasterxml.jackson.databind.JsonNode;

import javax.xml.ws.Response;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName: GaoDeMapController
 * @Description:   根据输入的地理名称获取高德地图的经纬度坐标
 * @Version: v1.0.0
 * @Author: Fu Hao
 * @Date: 2019/10/16 0016 下午 1:45
 * Modification History:
 * Date           Author      Version     Description
 * -------------------------------------------------------------
 * 2019/10/16 0016        Fu Hao      v1.0.0         创建
 */
@Controller
@RequestMapping("/mapController")
public class GaoDeMapController {


    /*private static String key="389880a06e3f893ea46036f030c94700";*/
    /**
     * 通过java api从高德地图获取经纬度
     *  address 位置
     *  output 返回结果格式
     *  key  高德key值，需申请
     */
    /*public void Distance() {
            //1、通过java api从高德地图获取经纬度
            String addressStr = "http://restapi.amap.com/v3/geocode/geo?key=9a491a13997579f985c98165bb68d127&s=rsv3&city=湖北省&address=十堰市";

        String getAddress = HttpUtils.get(addressStr + UrlEncoded.encodeString(address));
        JSONObject object = JSONObject.parseObject(getAddress);
        JSONArray geocodes = object.getJSONArray("geocodes");
        ExcelDetails details = ExcelDetails.dao.findById(id);
        if (geocodes.size() == 0) {
            details.set("status", 0);
        } else if (geocodes.size() == 1) {
            JSONObject trueAddress = geocodes.getJSONObject(0);
            String location = trueAddress.getString("location");
            String lngX = location.split(",")[0];
            String latY = location.split(",")[1];
        } else {
        }
    }*/
}
